<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateOauthsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('oauths', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->bigInteger('user_id')->unique();
            $table->string('third_party',50)->default('')->comment('third_party');
            $table->string('openid',50)->default('')->comment('第三方用户id');
            $table->string('union_id',50)->default('')->comment('第三方用户多个产品中的惟一 id,(如:微信平台)');
            $table->string('nickname',50)->default('')->comment('用户昵称');
            $table->string('access_token',512)->default('')->comment('第三方授权码');
            $table->dateTime('expire_at', 0)->comment('过期时间');
            $table->unsignedInteger('login_times')->default(0)->comment('登录次数');
            $table->unsignedInteger('click')->default(0)->comment('请求次数');// 规定一天只能请求2000次
            $table->text('more')->default('')->comment('第三方授权码');
            $table->ipAddress('visitor');
            $table->timestamps();
            $table->softDeletes();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('oauths');
    }
}
